<!-- -->
<template>
  <div class='header'>
    <div class="content">
      <div class="left" @click='goToHome'>
        <img src="@/assets/images/logo.png" alt="">
        <div class='title'>尚医通 预约挂号统一平台</div>
      </div>
      <div class="right">
        <p>帮助中心</p>
        <p class='login' @click='goToLogin' v-if='!userStore.userInfo.name'>登录/注册</p>
        <el-dropdown v-else>
          <span class="el-dropdown-link">
            {{ userStore.userInfo.name }}<el-icon class="el-icon--right"><arrow-down /></el-icon>
          </span>
          <template #dropdown>
            <el-dropdown-menu>
              <el-dropdown-item @click='dealClick(1)'>实名认证</el-dropdown-item>
              <el-dropdown-item @click='dealClick(2)'>挂号订单</el-dropdown-item>
              <el-dropdown-item @click='dealClick(3)'>就诊人管理</el-dropdown-item>
              <el-dropdown-item @click='dealClick(4)'>退出登录</el-dropdown-item>
            </el-dropdown-menu>
          </template>
        </el-dropdown>
      </div>
    </div>
  </div>
</template>

<script setup lang='ts'>
import { ref, reactive } from 'vue'
// import { useRouter } from 'vue-router'
// const router = useRouter()


import router from '@/router';

import { useUserStore } from '@/stores/user'
const userStore = useUserStore()
console.log(userStore);


const goToHome = () => {
  router.push('/home')
}

const goToLogin = () => {
  // userStore.dialogVisible = true
  userStore.changeDialog('open')
}

const dealClick = (index: number) => {
  if (index === 4) {
    userStore.logout()
    router.push('/home')
  }
}

</script>

<style lang='scss' scoped>
.header {
  height: 70px;
  width: 100%;
  display: flex;
  justify-content: center;
  position: fixed;
  z-index: 999;
  background-color: #fff;
  left: 0;
  .content {
    height: 100%;
    width: 1200px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    .left {
      display: flex;
      align-items: center;
      cursor: pointer;
      img {
        width: 50px;
        height: 50px;
        margin-right: 12px;
      }
      .title {
        font-size: 20px;
        color: #55a6fe;
      }
    }
    .right {
      display: flex;
      align-items: center;
      color: #bbb;
      cursor: pointer;
      .login {
        margin-left: 12px;
      }
      .el-dropdown {
        margin-left: 12px;
        margin-top: 8px;
        font-size: 16px;
      }
    }
  }
}
</style>
